package com.estronger.shopmanage.ui.install;
import android.app.Dialog;
import android.content.Intent;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.TextView;

import com.estronger.shopmanage.R;
import com.estronger.shopmanage.base.BaseActivity;
import com.estronger.shopmanage.base.MyApplication;
import com.estronger.shopmanage.bean.B31BuildDetail;
import com.estronger.shopmanage.bean.B31BuildDetail.BuildItem;
import com.estronger.shopmanage.bean.B34BuildDetailGoods;
import com.estronger.shopmanage.bean.B34BuildDetailGoods.BuildGoodsItem;
import com.estronger.shopmanage.manager.NetManager;
import com.estronger.shopmanage.ui.common.ViewActivity;
import com.estronger.shopmanage.ui.grab.activity.GrabPondActivity;
import com.estronger.shopmanage.ui.grab.bean.GrabOrderBean;
import com.estronger.shopmanage.ui.grab.presenter.GrabComPresenter;
import com.estronger.shopmanage.ui.grab.presenter.IGrabComView;
import com.estronger.shopmanage.ui.order.activity.SelectActionActivity;
import com.estronger.shopmanage.ui.order.bean.OrderAttributeBean;
import com.estronger.shopmanage.utils.MedialPlayerFunc;
import com.estronger.shopmanage.utils.Toast;
import com.estronger.shopmanage.view.AbnormalDeclareView;
import com.estronger.shopmanage.view.AppDialog;
import com.lidroid.xutils.http.RequestParams;
import com.soonfor.evaluate.tools.ComToast;
import com.soonfor.evaluate.tools.CustomDialog;
import com.soonfor.evaluate.tools.dialog.normal.NormalDialog;
import com.soonfor.evaluate.tools.dialog.normal.OnBtnClickL;
import com.soonfor.systemcodes.SystemCodes;

import java.util.ArrayList;
@SuppressWarnings("ResourceType")
public class BuildDetailActivity extends BaseActivity implements
		OnClickListener {
	/*
	 * 安装详情里的展示各个字符的TextView
	 */
	private TextView tv_build_name, tv_build_phone, tv_build_time,
			tv_build_address, tv_build_ridate, tv_build_need2, tv_build_remark,
			tv_build_voice_second2, tv_build_cts_test;// ,
	/*
	 * 安装货物的字符属性
	 */
	private TextView tv_goods_property, tv_goods_how_many, tv_goods_feature,
			tv_goods_name;
	private LinearLayout ll_before_contener, ll_ing_contener,
			ll_after_contener, ll_goods_contener, ll_bottom1, ll_bottom2,
			ll_bottom3, ll_tesimony_contener, ll_name_contener;
    private LinearLayout llfPhone;
	private View rootView, titleView, callView, smsView;
	private String dlvid, phaselv1, phaselv2, phaselv3, call_name;
	private ScrollView root;
	public static String send_deliv_id;//
	private Button play_bt;
	private boolean haveSetVoice = true, isComplesh = false,
			iftestimony = false;
	private ArrayList<String> imgArr = new ArrayList<String>();
	private RelativeLayout other;
	private GrabOrderBean.DataBean goBean;//抢单对象
	private TextView tvfButton;
	private RelativeLayout rl_selectImageList;//选择图片上传日期
	private TextView tvUpManTitle;//上传人的标题
	NormalDialog ndialog;

	B31BuildDetail detailInfo;//详细信息
	ArrayList<OrderAttributeBean> upManList = new ArrayList<>();
	String fsrid = "0";//上传图片选择位置的id
	Integer upManRequestCode = 100;//选择图片的code

	@Override
	protected void init() {
		isComplesh = getIntent().getBooleanExtra("isComplesh", false);
		iftestimony = getIntent().getBooleanExtra("iftestimony", false);
		dlvid = getIntent().getStringExtra("dlvid");
		try {
			goBean = (GrabOrderBean.DataBean) getIntent().getSerializableExtra("isGrabOrderBean");
		} catch (Exception e) {
			goBean = null;
		}
		RequestParams params = new RequestParams();
		if (isComplesh) {
			/**
			 * istgettaskdetail  安装完工接口
			 */
			params.addBodyParameter("sf_action", "istgettaskdetail");
			params.addBodyParameter("usercode", MyApplication.getUserCode());
			params.addBodyParameter("dlvid", dlvid);
			connect(params, NetManager.BUILD_DETAIL);
		} else {
			params.addBodyParameter("sf_action", "getistinfo");
			params.addBodyParameter("usercode", MyApplication.getUserCode());
			params.addBodyParameter("dlvid", dlvid);
			connect(params, NetManager.BUILD_DETAIL);
		}
		showDialog("获取安装详情中...", true);
	}

	@Override
	protected void initView() {
		rootView = View.inflate(this, R.layout.activity_task_detail, null);
		setContentView(rootView);
		tvfButton = findViewById(R.id.tvfButton);
		if (goBean != null) {//抢单
			tvfButton.setVisibility(View.VISIBLE);
			tvfButton.setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View view) {
					String hintText = "亲，抢单完成后请尽快与客户再次确认" + goBean.getTaskTypeDesc() + "日期，任务预期未处理，将会对您的信誉造成影响";
					ndialog = CustomDialog.getInstance().getNormalDialog(BuildDetailActivity.this, "温馨提示", hintText,
							new OnBtnClickL() {
								@Override
								public void onBtnClick(View view) {
									ndialog.dismiss();
									showDialog("抢单中...", true);
									new GrabComPresenter(BuildDetailActivity.this, new IGrabComView() {
										@Override
										public void refreshAfterGrabTask(boolean isSuccess, String msg) {
											if (isSuccess) {
												ComToast.showSuccessToast(BuildDetailActivity.this, "抢单成功");
												GrabPondActivity.ItemPosition = 0;
												BuildDetailActivity.this.finish();
											} else {
												ComToast.showFailToast(BuildDetailActivity.this, "抢单失败");
											}
											dimssDialog();
										}
									}).grabTask(goBean.getFtaskid(), goBean.getFtasktype());
								}
							});
					ndialog.show();
				}
			});
		} else {
			tvfButton.setVisibility(View.GONE);
		}
		root = (ScrollView) findViewById(R.id.detail_scroller);
		View child = View.inflate(this, R.layout.build_item_detail, null);
		root.addView(child);

		ll_bottom1 = (LinearLayout) findViewById(R.id.build_finish_bottom1);
		ll_bottom2 = (LinearLayout) findViewById(R.id.build_finish_bottom2);
		ll_bottom3 = (LinearLayout) findViewById(R.id.build_finish_bottom3);
		rl_selectImageList = (RelativeLayout) findViewById(R.id.rlfSelectImg);
		rl_selectImageList.setOnClickListener(onClickListener);
		tvUpManTitle = findViewById(R.id.tvfImgTitle);
		initTitle(root);
	}

	private void initTitle(View root) {
		titleView = root.findViewById(R.id.build_detail_title);
		tv_build_name = (TextView) root.findViewById(R.id.build_item_name);
		tv_build_phone = (TextView) root.findViewById(R.id.build_item_phone);
		tv_build_time = (TextView) root
				.findViewById(R.id.build_detail_appointment);
		tv_build_address = (TextView) root
				.findViewById(R.id.build_item_location);
		tv_build_remark = (TextView) findViewById(R.id.build_remark);
		ll_goods_contener = (LinearLayout) root.findViewById(R.id.goods_contener);

		tv_build_cts_test = (TextView) findViewById(R.id.cts_test);
		ll_name_contener = (LinearLayout) findViewById(R.id.cts_name_contener);
		llfPhone = root.findViewById(R.id.llfPhone);
		if (goBean != null) {
			llfPhone.setVisibility(View.GONE);
		} else {
			llfPhone.setVisibility(View.VISIBLE);
		}
		callView = root.findViewById(R.id.build_phone_call);
		smsView = root.findViewById(R.id.build_send_sms);

		callView.setOnClickListener(this);
		smsView.setOnClickListener(this);
	}

	@Override
	protected void onNetSuccess(int code, String result) {
		// Log.i("result", "DETAIL = " + result);

		if (NetManager.BUILD_DETAIL == code) {
			if (isComplesh) {//
				buildCompleshView(result);
			} else {
				buildNoCompleshView(result);
			}
		}
		super.onNetSuccess(code, result);
	}

	/*点击切换图片*/
	View.OnClickListener onClickListener = new View.OnClickListener(){
		@Override
		public void onClick(View view) {
			SelectActionActivity.openActivity(BuildDetailActivity.this, 8, upManList, fsrid, upManRequestCode);
		}
	};

	/**
	 * 当这个要安装的货物还没有完成时要展示的View
	 *
	 * @result 没有完成时的字符串信息
	 */
	public void buildNoCompleshView(String result) {
		B34BuildDetailGoods detail = gson.fromJson(result,
				B34BuildDetailGoods.class);
		if (detail.success && detail.data != null) {

			if (TextUtils.isEmpty(detail.data.buildname)) {
				tv_build_name.setText(detail.data.cstname);
			} else {
				tv_build_name.setText(detail.data.buildname + "-"
						+ detail.data.cstname);
			}
			// number.setText("送货单号:" + detail.data.dlvno);
			call_name = detail.data.cstname;
			tv_build_phone.setText(detail.data.cstmobile);
			tv_build_address.setText(detail.data.address);
			tv_build_time.setText("预约安装时间:" + detail.data.pidate);
			tv_build_remark.setText(detail.data.remark);

			initBuildItem(detail.data.istitem);
		}
	}

	/**
	 * 初始化安装货物信息
	 * 
	 * @param istitem
	 *            安装货物实体
	 */
	public void initBuildItem(ArrayList<BuildGoodsItem> istitem) {
		// 测量货物的详细信息
		for (int i = 0; i < istitem.size(); i++) {
			BuildGoodsItem data = istitem.get(i);
			View v = View.inflate(this, R.layout.goods_condition, null);
			TextView goods_name = (TextView) v.findViewById(R.id.goods_name);
			TextView goods_count = (TextView) v.findViewById(R.id.goods_count);
			TextView goods_property = (TextView) v
					.findViewById(R.id.goods_property);
			ImageView goods_img = (ImageView) v
					.findViewById(R.id.goods_item_img);
			TextView goods_feature = (TextView) v
					.findViewById(R.id.goods_feature);

			v.setTag(data.dlvitemid);

			goods_name.setText(data.goodsname);
			goods_property.setText(data.sizedesc);
			goods_count.setText(data.qty);
			goods_feature.setText(data.unitname);
			MyApplication.imageLoader.displayImage(NetManager.getDownloadURL()
					+ "?filepath=" + data.simplepicfile, goods_img,
					MyApplication.options);

			LinearLayout condition_group = (LinearLayout) v
					.findViewById(R.id.item_conditions);
			for (int j = 0; j < data.conditionitem.size() && j < 10; j++) {
				View item = View.inflate(this, R.layout.condition_item, null);
				// TextView pos_tv = (TextView)
				// item.findViewById(R.id.condition_position);
				TextView content = (TextView) item
						.findViewById(R.id.condition_content);
				CheckBox cb = (CheckBox) item.findViewById(R.id.condition_cb);

				item.setTag(data.conditionitem.get(j).itemid);
				// pos_tv.setText(pos[j]);
				content.setText(data.conditionitem.get(j).content);
				if ("1".equals(data.conditionitem.get(j).ifcheck)) {
					cb.setChecked(true);
				}
				cb.setClickable(false);
				condition_group.addView(item);
			}
			ll_goods_contener.addView(v);
		}
	}

	/**
	 * 当一个安装货物已完成安装时展示的View信息
	 * 
	 * @param result
	 */
	public void buildCompleshView(String result) {
		B31BuildDetail detail = gson.fromJson(result, B31BuildDetail.class);
		if (detail.success && detail.data != null) {
			this.detailInfo = detail;
			upManList.clear();
			if (detail.data.upmanlist != null && detail.data.upmanlist.size() > 0){
				for (B31BuildDetail.InstallUpMan upMan : detail.data.upmanlist) {
					OrderAttributeBean bean = new OrderAttributeBean();
					bean.setAttId(upMan.fsrcid);
					bean.setAttName(upMan.ftitle);
					upManList.add(bean);
				}
				fsrid = upManList.get(0).getAttId();
				tvUpManTitle.setText(upManList.get(0).getAttName());
			}
			handleFileValue(fsrid);
		}
	}

	/*处理附件信息*/
	void handleFileValue(String fsrcid){
		B31BuildDetail detail = detailInfo;

		/*如果启用可以选中多张图片，则可选择图片*/
		if (SystemCodes.getInstance().getDSM_IfFinishCanUpdateAttaOnly() == 1){
			rl_selectImageList.setVisibility(View.VISIBLE);
		}else {
			rl_selectImageList.setVisibility(View.GONE);
			fsrcid = "0";//设置成所有的图片都可以显示
		}
		if (detail.data.iststatus == 1) {
			initBottom2();
			// 下面是当安装信息完成时，bottom2独有的内容
			ll_bottom1.setVisibility(View.GONE);
			titleView.setVisibility(View.GONE);
			ll_bottom2.setVisibility(View.VISIBLE);
			ll_name_contener.setVisibility(View.VISIBLE);
			tv_build_name = (TextView) ll_name_contener
					.findViewById(R.id.cts_name);
			if (TextUtils.isEmpty(detail.data.buildname)) {
				tv_build_name.setText(detail.data.cstname);
			} else {
				tv_build_name.setText(detail.data.buildname + "-"
						+ detail.data.cstname);
			}

			tv_build_ridate.setText(detail.data.ridate);
			tv_build_need2.setText(detail.data.istremark);

			/*移除已经添加的视图*/
			ll_before_contener.removeAllViews();
			ll_ing_contener.removeAllViews();
			ll_after_contener.removeAllViews();
			for (int i = 0; i < detail.data.imgitem.size(); i++) {
				B31BuildDetail.BuildIMG buildIMG = detail.data.imgitem.get(i);
				/*不是选中的id，并且不是全部的则不显示*/
				if (!buildIMG.srcid.equals(fsrcid) && !fsrcid.equals("0")){
					continue;
				}
				if (detail.data.imgitem.get(i).phaselv == 1) {
					RelativeLayout item = (RelativeLayout) View.inflate(
							this, R.layout.img, null);
					ImageView iv = (ImageView) item.getChildAt(0);
					MyApplication.imageLoader.displayImage(
							NetManager.getDownloadURL() + "?filepath="
									+ detail.data.imgitem.get(i).imgpath,
							iv, MyApplication.options);
					iv.setTag("phaselv1");
					phaselv1 = NetManager.getDownloadURL() + "?filepath="
							+ detail.data.imgitem.get(i).imgpath;
					ll_before_contener.addView(item);
				}
				if (detail.data.imgitem.get(i).phaselv == 2) {
					RelativeLayout item = (RelativeLayout) View.inflate(
							this, R.layout.img, null);
					ImageView iv = (ImageView) item.getChildAt(0);
					MyApplication.imageLoader.displayImage(
							NetManager.getDownloadURL() + "?filepath="
									+ detail.data.imgitem.get(i).imgpath,
							iv, MyApplication.options);
					iv.setTag("phaselv2");
					phaselv2 = NetManager.getDownloadURL() + "?filepath="
							+ detail.data.imgitem.get(i).imgpath;
					ll_ing_contener.addView(item);
				}
				if (detail.data.imgitem.get(i).phaselv == 3) {
					RelativeLayout item = (RelativeLayout) View.inflate(
							this, R.layout.img, null);
					ImageView iv = (ImageView) item.getChildAt(0);
					MyApplication.imageLoader.displayImage(
							NetManager.getDownloadURL() + "?filepath="
									+ detail.data.imgitem.get(i).imgpath,
							iv, MyApplication.options);
					iv.setTag("phaselv3");
					phaselv3 = NetManager.getDownloadURL() + "?filepath="
							+ detail.data.imgitem.get(i).imgpath;
					ll_after_contener.addView(item);
				}
			}
		}

		if (iftestimony) {//
			initBottom3();
			// 下面是提交证言信息完成时，bottom3独有的内容
			ll_bottom3.setVisibility(View.VISIBLE);

			/*移除已添加的视图*/
			ll_tesimony_contener.removeAllViews();
			for (int i = 0; i < detail.data.voiceitem.size(); i++) {
				B31BuildDetail.BuildVoice buildVoice = detail.data.voiceitem.get(i);
				/*不是选中的id，并且不是全部的则不显示*/
				if (!buildVoice.srcid.equals(fsrcid) && !buildVoice.srcid.equals("0")){
					continue;
				}
				if (detail.data.voiceitem.get(i).filetype.equals("1")) {
					// 对安装图片进行处理
					imgArr.add(detail.data.voiceitem.get(i).voicepath);
					RelativeLayout item = (RelativeLayout) View.inflate(
							this, R.layout.img_item_big, null);
					ImageView iv = (ImageView) item.getChildAt(0);
					MyApplication.imageLoader
							.displayImage(
									NetManager.getDownloadURL()
											+ "?filepath="
											+ detail.data.voiceitem.get(i).voicepath,
									iv, MyApplication.options);
					ll_tesimony_contener.addView(item);
				} else if (detail.data.voiceitem.get(i).filetype.equals("2")) {
					// 对录音进行处理
					if (haveSetVoice) {
						haveSetVoice = false;
						play_bt.setTag(NetManager.getDownloadURL()
								+ "?filepath="
								+ detail.data.voiceitem.get(i).voicepath);
						other.setVisibility(View.VISIBLE);

						int countTime = 0;
						try {
							countTime = Integer.parseInt(detail.data.voiceitem.get(i).filelenth);
						}catch (Exception e){
							e.printStackTrace();
						}
						if (countTime > 0) {
							String timeText;
							if ((countTime % 60) < 10) {
								timeText = (countTime / 60) + "'0"
										+ (countTime % 60);
							} else {
								timeText = (countTime / 60) + "'"
										+ (countTime % 60);
							}
							tv_build_voice_second2.setText(timeText + "\"");
						}
					}
				}
			}
			tv_build_cts_test.setText(detail.data.testimonytxt);
		}

		// 下面是当安装信息未完成时，公共的内容
		tv_build_remark.setText(detail.data.istremark);
		// build_count.setText(detail.data.item.size() + "");
		ll_goods_contener.removeAllViews();
		for (int i = 0; i < detail.data.item.size(); i++) {
			BuildItem item = detail.data.item.get(i);
			View view = View.inflate(this, R.layout.goods_item, null);

			ImageView goods_img = (ImageView) view
					.findViewById(R.id.goods_item_img);
			tv_goods_name = (TextView) view.findViewById(R.id.goods_name);
			tv_goods_property = (TextView) view
					.findViewById(R.id.goods_property);
			tv_goods_how_many = (TextView) view
					.findViewById(R.id.goods_count);
			tv_goods_feature = (TextView) view
					.findViewById(R.id.goods_feature);

			tv_goods_name.setText(item.goodsname);
			tv_goods_property.setText(item.sizedesc);
			tv_goods_how_many.setText(item.qty + "");
			tv_goods_feature.setText(item.unitname);
			if (null != detail.data.item) {
				String path = NetManager.getDownloadURL() + "?filepath="
						+ item.simplepicfile;
				goods_img.setTag(path);
				MyApplication.imageLoader.displayImage(path, goods_img,
						MyApplication.options);
			}

			ll_goods_contener.addView(view);
		}
	}

	/**
	 * 点击展示安装条件
	 * 
	 * @param view
	 */
	public void showCondition(View view) {
		ImageView rb = (ImageView) view;
		View condition_group = ((View) view.getParent().getParent())
				.findViewById(R.id.item_conditions);
		if (condition_group.getVisibility() == View.VISIBLE) {
			rb.setBackgroundResource(R.drawable.hide_view_down);
			condition_group.setVisibility(View.GONE);
		} else {
			rb.setBackgroundResource(R.drawable.hide_view_up);
			valueAnim(0, condition_group.getMeasuredHeight(), condition_group);
			condition_group.setVisibility(View.VISIBLE);
		}
	}

	private MedialPlayerFunc mPlayer;

	public void playVoice(final View view) {
		// Log.i("MM", "voice play");
		if (view.getTag() != null) {
			if (null == mPlayer) {
				mPlayer = MedialPlayerFunc.getInstance();
			}
			if (mPlayer.getIsPlaying()) {// 正在播放时的处理
				mPlayer.pause();
				stopAnim(view);
			} else {// 播放吧
				mPlayer.start(view.getTag().toString(),
						new OnCompletionListener() {
							@Override
							public void onCompletion(MediaPlayer mp) {
								stopAnim(view);
								mPlayer.setPlaying(false);
							}
						});
				mPlayer.setPlaying(true);
				startAnim(view);
			}

		} else {
			Toast.show(this, "读取录音文件失败", 2000);
		}
	}

	AnimationDrawable rocketAnimation;

	public void startAnim(View view) {
		view.setBackgroundResource(R.anim.play_voice_ani);
		rocketAnimation = (AnimationDrawable) view.getBackground();
		rocketAnimation.start();
	}

	public void stopAnim(View view) {
		if (rocketAnimation != null) {
			rocketAnimation.stop();
		}
		view.setBackgroundResource(R.drawable.play_bt);
	}

	private void initBottom2() {
		tv_build_ridate = (TextView) ll_bottom2
				.findViewById(R.id.built_time_ridate);
		tv_build_need2 = (TextView) ll_bottom2.findViewById(R.id.build_bottom2_need);

		ll_before_contener = (LinearLayout) findViewById(R.id.build_before_contener);
		ll_ing_contener = (LinearLayout) findViewById(R.id.build_ing_contener);
		ll_after_contener = (LinearLayout) findViewById(R.id.build_after_contener);

		ll_before_contener.setVisibility(View.VISIBLE);
		ll_ing_contener.setVisibility(View.VISIBLE);
		ll_after_contener.setVisibility(View.VISIBLE);
	}

	private void initBottom3() {
		play_bt = (Button) ll_bottom3.findViewById(R.id.play_bt);
		tv_build_voice_second2 = (TextView) findViewById(R.id.voice_second2);
		ll_tesimony_contener = (LinearLayout) ll_bottom3
				.findViewById(R.id.tesimony_img_contener);
		other = (RelativeLayout) ll_bottom3.findViewById(R.id.others);
	}

	private Dialog dialog;

	@Override
	public void onClick(View v) {
		String number = tv_build_phone.getText().toString();
		switch (v.getId()) {
		case R.id.build_send_sms:
			if (isRightNumber(number)) {
				Uri uri = Uri.parse("smsto:" + number);
				Intent intent = new Intent(Intent.ACTION_SENDTO, uri);
				startActivity(intent);
			}
			break;
		case R.id.build_phone_call:
			if (isRightNumber(number)) {
				dialog = AppDialog.createDialog(this, call_name, number, this,
						send_deliv_id);
				dialog.show();
			}
			break;
		case R.id.ok:
			Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"
					+ number));
			startActivity(intent);
			dialog.dismiss();
			break;
		}
	}

	public void viewPhoto(View view) {
		view.setBackgroundResource(R.drawable.goods_default);
		if (null != view.getTag()) {
			if (view.getTag().toString().equals("phaselv1")) {
				showGoodsPop(phaselv1);
			} else if (view.getTag().toString().equals("phaselv2")) {
				showGoodsPop(phaselv2);
			} else if (view.getTag().toString().equals("phaselv3")) {
				showGoodsPop(phaselv3);
			}
		} else {
			Intent intent = new Intent(this, ViewActivity.class);
			intent.putStringArrayListExtra("imgs", imgArr);
			intent.putExtra("isLocal", false);
			startActivity(intent);
		}
	}

	public void viewGoods(View view) {
		// Log.i("MM", "viewGoods");
		showGoodsPop(view.getTag().toString());
	}

	private PopupWindow sharedPop;

	public void showGoodsPop(String url) {
		if (sharedPop == null) {
			View contentView = View.inflate(this, R.layout.shared_pop_window,
					null);
			sharedPop = new PopupWindow(contentView, LayoutParams.MATCH_PARENT,
					LayoutParams.MATCH_PARENT, true);
			sharedPop.setAnimationStyle(R.style.goods_pop);
			sharedPop.setBackgroundDrawable(new BitmapDrawable());
			sharedPop.setFocusable(true);
		}
		ImageView iv = (ImageView) sharedPop.getContentView().findViewById(
				R.id.goods_img_big);
		iv.setImageResource(R.drawable.goods_default);
		MyApplication.imageLoader.displayImage(url, iv, MyApplication.options);
		sharedPop.showAtLocation(rootView, Gravity.CENTER, 0, 0);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
		super.onActivityResult(requestCode, resultCode, data);
		if (requestCode == upManRequestCode){
			if (data != null) {
				OrderAttributeBean attributeBean = (OrderAttributeBean) data.getParcelableExtra(AbnormalDeclareView.BIND_DATA);
				fsrid = attributeBean.getAttId();
				tvUpManTitle.setText(attributeBean.getAttName());
				handleFileValue(fsrid);
			}
		}
	}

	@Override
	public void onBackPressed() {
		if (null != sharedPop && sharedPop.isShowing()) {
			sharedPop.dismiss();
		} else {
			super.onBackPressed();
		}
	}

	@Override
	protected void onDestroy() {
		if (sharedPop != null && sharedPop.isShowing()) {
			sharedPop.dismiss();
		}
		super.onDestroy();
	}

	public void closeGoodsPop(View view) {
		sharedPop.dismiss();
	}
}
